After using randr to get a list of monitors, sort the list such that the
authorRay Strode <rstrode@redhat.com>
Fri, 20 Feb 2009 04:42:33 +0000 (04:42 +0000)
committerRay Strode <halfline@src.gnome.org>
Fri, 20 Feb 2009 04:42:33 +0000 (04:42 +0000)
2009-02-19  Ray Strode  <rstrode@redhat.com>

* gdk/x11/gdkscreen-x11.c
(monitor_compare_function), (init_randr13):
After using randr to get a list of monitors,
sort the list such that the biggest output
of "cloned" outputs comes first in the list.
This helps apps that don't generally handle
overlapping outputs to work better in randr
clone mode.

svn path=/trunk/; revision=22386

ChangeLog
gdk/x11/gdkscreen-x11.c

index 7e2df8dc91a446b1de4c8c66bfdc358ac0cf682c..69fd9b8ca284a7989c34713de5d7a69713be891d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-02-19  Ray Strode  <rstrode@redhat.com>
+
+       * gdk/x11/gdkscreen-x11.c
+       (monitor_compare_function), (init_randr13):
+       After using randr to get a list of monitors,
+       sort the list such that the biggest output
+       of "cloned" outputs comes first in the list.
+       This helps apps that don't generally handle
+       overlapping outputs to work better in randr
+       clone mode.
+
 2009-02-19  Sven Neumann  <sven@gimp.org>
 
        * gdk/directfb/gdkwindow-directfb.c
index 3b9a8455f171b421100e05a6386611e15771a2b8..e6478006bfefff9c6b7c4fd6a342e49efd2319fe 100644 (file)
@@ -663,6 +663,31 @@ init_fake_xinerama (GdkScreen *screen)
   return FALSE;
 }
 
+static int
+monitor_compare_function (GdkX11Monitor *monitor1,
+                          GdkX11Monitor *monitor2)
+{
+  /* Sort the leftmost/topmost monitors first.
+   * For "cloned" monitors, sort the bigger ones first
+   * (giving preference to taller monitors over wider
+   * monitors)
+   */
+
+  if (monitor1->geometry.x != monitor2->geometry.x)
+    return monitor1->geometry.x - monitor2->geometry.x;
+
+  if (monitor1->geometry.y != monitor2->geometry.y)
+    return monitor1->geometry.y - monitor2->geometry.y;
+
+  if (monitor1->geometry.height != monitor2->geometry.height)
+    return - (monitor1->geometry.height - monitor2->geometry.height);
+
+  if (monitor1->geometry.width != monitor2->geometry.width)
+    return - (monitor1->geometry.width - monitor2->geometry.width);
+
+  return 0;
+}
+
 static gboolean
 init_randr13 (GdkScreen *screen)
 {
@@ -732,6 +757,8 @@ init_randr13 (GdkScreen *screen)
       return FALSE;
     }
 
+  g_array_sort (monitors,
+                (GCompareFunc) monitor_compare_function);
   screen_x11->n_monitors = monitors->len;
   screen_x11->monitors = (GdkX11Monitor *)g_array_free (monitors, FALSE);